﻿using Ruici.BLL;
using RuiciWebSite.Common;
using RuiciWebSite.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace RuiciWebSite.Controllers
{
    public class NewsController : Controller
    {
        DocumentBll document = new DocumentBll();
        // GET: News
        public ActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 全部信息文档
        /// </summary>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetAllDocumentList(PageInfoViewModel pageInfo)
        {
            int iTotalCount = 0;
            pageInfo.curPageRecord = document.GetArticleList("clinics_news", 0, pageInfo.pageSize, pageInfo.pageCurrent, pageInfo.keyWord, out iTotalCount);
            pageInfo.totalCount = iTotalCount;
            pageInfo.pageCount = (iTotalCount + pageInfo.pageSize - 1) / pageInfo.pageSize;
            pageInfo.ImgUrl = RuiciCommoms._sImgPath;
            if (pageInfo != null)
                return Json(pageInfo, JsonRequestBehavior.AllowGet);

            return Json(new ReturnCode(-1, "没有找到相关文章"), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 诊所公告
        /// </summary>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetAnnouncementDocumentList(PageInfoViewModel pageInfo)
        {
            int iTotalCount = 0;
            pageInfo.curPageRecord = document.GetArticleList("clinics_news", 251, pageInfo.pageSize, pageInfo.pageCurrent, pageInfo.keyWord, out iTotalCount);
            pageInfo.totalCount = iTotalCount;
            pageInfo.pageCount = (iTotalCount + pageInfo.pageSize - 1) / pageInfo.pageSize;
            pageInfo.ImgUrl = RuiciCommoms._sImgPath;
            if (pageInfo != null)
                return Json(pageInfo, JsonRequestBehavior.AllowGet);

            return Json(new ReturnCode(-1, "没有找到相关文章"), JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 诊所动态
        /// </summary>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult GetTrendsDocumentList(PageInfoViewModel pageInfo)
        {
            int iTotalCount = 0;
            pageInfo.curPageRecord = document.GetArticleList("clinics_news", 252, pageInfo.pageSize, pageInfo.pageCurrent, pageInfo.keyWord, out iTotalCount);
            pageInfo.totalCount = iTotalCount;
            pageInfo.pageCount = (iTotalCount + pageInfo.pageSize - 1) / pageInfo.pageSize;
            pageInfo.ImgUrl = RuiciCommoms._sImgPath;
            if (pageInfo != null)
                return Json(pageInfo, JsonRequestBehavior.AllowGet);

            return Json(new ReturnCode(-1, "没有找到相关文章"), JsonRequestBehavior.AllowGet);
        }
    }
}